/**
 * Created by beck on 2015/7/6.
 */
$(document).ready(function(){
	$("#partName").html(window.localStorage.getItem("groupNames"));
    $("body").height($(window).height());
    var $headerHeight = $("header").height();
    var $footerHeight = $("footer").height();
    var $bannerHeight = $("#banner").height();
    var $yunzo_bg = $("body").height()-($headerHeight+$footerHeight+$bannerHeight);
    $("#yunzo-bg").height($yunzo_bg);
    getaAd();
    getMemberConpanyList();
    $("#dy-state").attr("href","trends.html?mid="+getUrlParam("mid")+"&groupid="+getUrlParam("groupid"));
    $("#inform").attr("href","inform/infromList.html?mid="+getUrlParam("mid")+"&groupid="+getUrlParam("groupid"));
    $("#eadd_list").attr("href","address/addressList.html?mid="+getUrlParam("mid")+"&groupid="+getUrlParam("groupid"));
    $("#commonadd_list").attr("href","address/usualAddress.html?mid="+getUrlParam("mid")+"&businessId="+getUrlParam("businessId"));
    $("#personal").attr("href","mine/myPage2.html?mid="+getUrlParam("mid")+"&groupid="+getUrlParam("groupid"));
    $("#index-1").attr("href","yunzoquan/yunzoIndex.html?mid="+getUrlParam("mid")+"&businessId="+getUrlParam("businessId"));
    $("#show-part").attr("href","show_part.html?mid="+getUrlParam("mid")+"&businessId="+getUrlParam("businessId"));
    $("#sub-dem").attr("href","sub_dem.html?mid="+getUrlParam("mid")+"&groupid="+getUrlParam("groupid"));
    $("#logo a").attr("href","chamber_detial.html?groupid="+getUrlParam("groupid"));
});
var t= n = 0,count;
$(document).ready(function() {
	
    count = $("#banner_list a").length;
    $("#banner_list a:not(:first-child)").hide();
    $("#banner>ul>li").click(function(){
        var i = $(this).index();
        n = i;
        if(i>=count) return;
        $("#banner_list a").filter(":visible").fadeOut(500).parent().children().eq(i).fadeIn(500);
        document.getElementById("banner").style.background ="";
        $(this).toggleClass("on");
        $(this).siblings().removeAttr("class");
    });
    t = setInterval("showAuto()",4000);
    $("#banner").hover(function(){
        clearInterval(t);
    },function(){
        t = setInterval("showAuto()",4000);
    });
});
//获取投放广告
function getaAd() {
	var Post="mid="+basedata.mid+"&groupid="+basedata.groupid+"&token="+basedata.token+"&adtype=1&did=00000";
	$.ajax({
		url:'../api/getadimagebymidlist',
		type:'post',
		data:Post,
		success:function(msg){
			if(msg.code ==100){
				$("#adv").attr("src",msg.data);
			}
		}
	});
}
//获取广告详情
function getAdinfo(adid) {
	var Post = "mid="+basedata.mid+"&groupid="+basedata.groupid+"&token="+basedata.token+"&did=0000"+"&adid="+adid;
	$.ajax({
		url:'../api/getadinfobyadids',
		type:'post',
		data:Post,
		success:function(){
			
		}
	});
}
//获取个人公司列表
function getMemberConpanyList() {
	var Post = "mid="+basedata.mid+"&groupid="+basedata.groupid+"&token="+basedata.token+"&did=00000"+
	"&fromgroupid="+basedata.groupid+"&frommid="+basedata.mid+"&pagesize=10";
	$.ajax({
		url:'../api/group/getmembercompanylist',
		type:'post',
		data:Post,
		success:function(msg){
			
		}
	});
}
function showAuto() {
    n = n >= (count - 1) ? 0 : ++n;
    $("#banner>ul>li").eq(n).trigger("click");
}
function getUrlParam(name) {
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
	var r = window.location.search.substr(1).match(reg);
	if (r != null) return unescape(r[2]); return null;
}